<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>
            /* 
                数组
                    for循环
                    for...in
                    foreach
                    for...of

                对象
                    for...in

                set  for...of
                map  for...of
            */
           var arr = [10, 20, 30, 40, 50];
           for(var i = 0; i < arr.length; i++){
               document.write("for循环：" + arr[i] + ", " + i + "<br/>");
           }

           for(var i in arr){
               document.write("for...in遍历：" + arr[i] + ", " + i + "<br/>");
           }

           arr.forEach(function(item, index){
                document.write("forEach：" + item + ", " + index + "<br/>");
           })

           //通过for...of遍历数组
           for(var item of arr){
               /* 
                 item是当前遍历到的元素
               */
               document.write("for...of：" + item + "<br/>");
           }


           var person = {
               username: "钢铁侠",
               age: 20,
               sex: "男"
           };

           for(var attr in person){
               /* 
                  attr   遍历到的对象的属性
               */
               document.write("对象：" + attr + person[attr] + "<br/>");
           }
        </script>
        
    </head>
    <body>
        
    </body>
</html>